<template>
  <div class="app-container">
    <uc-table url="/admin/inAlarmRecord/getInAlarmRecordPage" name="报警记录" ref="fireInfoTable" pageable table-border :search-form="searchForm">
      <template slot="searchForm">
        <el-form size="mini" :inline="true" :model="searchForm" class="demo-form-inline filter-container">
          <!--搜索输入框-->
          <el-form-item>
            <el-input type="text" v-model="searchForm.title" placeholder="请输入报警名称" clearable @clear="clearInput()"></el-input>
          </el-form-item>
          <!--搜索按钮--新增按钮-->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" class="filter-item" @click="handleSearch()">查询</el-button>
          </el-form-item>
        </el-form>
      </template>
      <template slot="columns">
        <el-table-column prop="title" label="报警名称" align="left" :show-overflow-tooltip="true"></el-table-column>-->
        <el-table-column prop="reportPersonName" label="上报人" align="left" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="reportTime" label="上报时间 " align="left" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{scope.row.reportTime |dateFormat}}
          </template>
        </el-table-column>
        <el-table-column prop="regionName" label="关联区域" align="left" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{scope.row.regionName||"暂无关联区域"}}
          </template>
        </el-table-column>
        <el-table-column prop="handleStatus" label="处理状态 " align="left" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            {{scope.row.handleStatus| alarmStatus}}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作" width="180" align="left" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <!--编辑按钮-->
            <!--                        <el-button size="mini" icon="el-icon-edit" type="primary" @click="handleEdit(scope.row)">编辑</el-button>-->
            <el-button size="mini" icon="el-icon-info" type="success" @click="handleInfo(scope.row)">详情</el-button>
            <el-button size="mini" type="danger" icon="el-icon-delete" :loading="deleteLoading" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </template>
    </uc-table>
  </div>
</template>

<script>
import UcTable from "@/components/UcTable/index.vue";
import {deleteInFireInfo} from "@/api/fireInfo"

export default {
  name: "fireInfoList",
  components: {UcTable},
  data(){
    return{
      searchForm:{
        deleted:false,
        type:1,
      },

      deleteLoading:false,
      enterpriseDominantList:[]
    }
  },
  created() {

  },
  methods:{
    handleSearch(){
      this.$refs.fireInfoTable.getTableData(1)
    },
    handleInfo(val){
      this.$router.push("/fireAlarm/drillInfo/"+val.ucId)
    },
    clearInput(){
      //清除输入框
      this.searchForm.name = null
      this.handleSearch()
    },

    handleDelete(val){
      this.$confirm('您确定要执行删除'+val.name+'这个报警记录吗？', '提醒信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.deleteLoading = true
        deleteInFireInfo(val).then(res=>{
          this.deleteLoading = false
          this.$notify.success({
            title: '成功',
            message: "删除报警记录成功"
          })
          this.handleSearch()
        }).catch(res=>{
          this.deleteLoading = false
          this.$notify.error({
            title: '失败',
            message: res.msg
          })
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    }
  }
}
</script>

<style scoped>

</style>